package ssm.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import ssm.scheduledJob.CheckWorkAll;
import ssm.scheduledJob.Perception;

import java.util.HashMap;
import java.util.Map;

@Controller
@RequestMapping("/job")
public class JOBController {

    @Autowired
    private CheckWorkAll checkWorkAll;
    @Autowired
    private Perception perception;

   

    /**
     * 每天定时任务,自动计算当天考勤记录
     */
    @RequestMapping("/updateCheckByToday")
    @ResponseBody
    @Scheduled(cron = "10 0 0/12 * * ? ")
//    @Scheduled(cron = "10 0/3 15 * * ? ")
    public void updateCheck(){
        System.out.println("开始任务");
        checkWorkAll.updateCheckWorkAllByToday();
    }

    @RequestMapping("/updateCheckByDateList")
    @ResponseBody
    public void updateCheck(@RequestParam("startDate")String startDate,
                              @RequestParam("endDate")String endDate){
        System.out.println("开始任务");
        checkWorkAll.updateCheckWorkAllByDateList(startDate,endDate);
    }


        @RequestMapping("/updateTrackPercetionByList")
    @ResponseBody
    public void updateTrackPercetion(String startDate,String endDate){
        perception.updatePerceptionByList(startDate,endDate);
    }

    @Scheduled(cron = "10 59 0/1 * * ? ")
    @RequestMapping("/updateTrackPercetionByToday")
    @ResponseBody
    public void updateTrackPercetion(){
        perception.updatePerceptionByToday();
    }


    @RequestMapping("/index.do")
    @ResponseBody
    public Map<String,Object> toIndex(String name){
        Map<String,Object> result=new HashMap<String, Object>(2);
        result.put("name",name);
        result.put("age",18);

        return result;
    }





}
